package com.example.jinzproduct.server.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.plugins.Page;
import com.example.commons.entity.OrganizationRolesDO;
import com.example.commons.vo.MyOrgRolesDeVo;
import com.example.commons.vo.MyOrgRolesVo;
import com.example.commons.vo.OrgRolesListVo;
import com.example.jinzproduct.dao.OrganizationRolesDao;
import com.example.jinzproduct.server.OrganizationRolesService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 
 * <pre>
 * 机构角色表
 * </pre>
 * <small> 2020-02-24 21:00:11 | lance</small>
 */
@Service
public class OrganizationRolesServiceImpl extends ServiceImpl<OrganizationRolesDao, OrganizationRolesDO> implements OrganizationRolesService {

    @Override
    public  List <MyOrgRolesDeVo> details(String id) {
        List <MyOrgRolesDeVo> myOrgRolesDeVo=   baseMapper.details(id);
        for(MyOrgRolesDeVo li:myOrgRolesDeVo){

        if(li.getRoleType().equals("5")){
            li.setRoleType("幼儿照护职业技能等级证书");
        }else {
            li.setRoleType("产后恢复职业技能等级证书");
        }
        }
        return myOrgRolesDeVo;
    }

    @Override
    public Page<OrgRolesListVo> selecHotSearchOrg() {
        // 新建分页
        Page<OrgRolesListVo> page = new Page<OrgRolesListVo>();
        List<OrgRolesListVo> list=   this.baseMapper.selecHotSearchOrg();
           for(OrgRolesListVo li:list){
               if(li.getRoleType().equals("5")){
                    li.setRoleType("幼儿照护职业技能等级证书");
               }else {
                   li.setRoleType("产后恢复职业技能等级证书");
               }
           }

        return page.setRecords(list);
    }

    @Override
    public Page<OrgRolesListVo> selectListPage(int current, int number, Map map) {

        // 新建分页
        Page<OrgRolesListVo> page = new Page<OrgRolesListVo>(current, number);
        return page.setRecords(this.baseMapper.dyGetUserList(page,map));
    }

    @Override
    public Integer selectListCount(int current, int number, Map map) {
        // 新建分页
        Page<OrgRolesListVo> page = new Page<OrgRolesListVo>(current, number);
        Integer count=this.baseMapper.selectListCount(page,map);
        return count;


    }

    @Override
    public Page<MyOrgRolesVo> selByUserId(int current, int number, Long userId) {

        // 新建分页
        Page<MyOrgRolesVo> page = new Page<MyOrgRolesVo>(current, number);

        return page.setRecords(this.baseMapper.selByUserId(page,userId));

    }

    @Override
    public Long selById(Map map){
        return baseMapper.selById(map);
    }

    @Override
    public List<Map<Object,Object>> selByRoleType(Integer roleType){
        return baseMapper.selByRoleType(roleType);
    }

    @Override
    public int selNoReviewAll(){
        return this.baseMapper.selNoReviewAll();
    }

    @Override
    public List<Map> selByRoleProvince(Map map){
        return this.baseMapper.selByRoleProvince(map);
    }

    @Override
    public String selByIdProName(Map map){
        return this.baseMapper.selByIdProName(map);
    }
}
